import React from 'react'
import ChannelStore from './channel.Store'
import { CounterStore } from './counterStore'
import { ListStore } from './listStore'
import LoginStore from './login.Store'
import { TaskStore } from './taskStore'
import UserStore from './user.Store'

class RootStore {
  constructor() {
    this.counterStore = new CounterStore()
    this.listStore = new ListStore()
    this.taskStore = new TaskStore()
    this.loginStore = new LoginStore()
    this.userStore = new UserStore()
    this.channelStore = new ChannelStore()
  }
}

const rootStore = new RootStore()

// context机制的数据查找链  Provider如果找不到 就找createContext方法执行时传入的参数
const context = React.createContext(rootStore)
const useStore = () => React.useContext(context)

export { useStore }
